package restless.utilities.testing {

	import flash.display.*;
	import flash.display3D.VertexBuffer3D;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.geom.Vector3D;
	import flash.utils.*;
	import flash.text.*;
	import flash.system.System;
	import restless.utilities.geom.RLERect;
	
	public class rectSpeedTest extends Sprite {
		private var __logger:TextField = new TextField();
		private var s:String = "";
		private function row(...cols): void {
			__logger.appendText(cols.join(", ") + "\n");
		}
		
		public function rectSpeedTest() {
			__logger.autoSize = TextFieldAutoSize.LEFT;
			addChild(__logger);
			
			var point:Point = new Point(2, 2);
			var vect3:Vector3D = new Vector3D(2, 2);
			var rec:Rectangle = new Rectangle(5, 5, 5, 5);
			var rleRect:RLERect = new RLERect(5, 5, 5, 5);
			var n:Number;
			var i:int = 0;
			var beforeTime:int;
			var afterTime:int;
			var castTime:int;
			//var i:uint;
			var len:uint = 100000;
			trace("itterations: " + len);
			
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				rleRect.y = 2;
				
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("RLERect ", castTime);
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				point.y = 2;
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("native point ", castTime);
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				rec.y = 2;
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("native rec", castTime);
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				vect3.y = 2;
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("Vect3D ", castTime);
			
			
			
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				rleRect = new RLERect();
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("RLERect creation", castTime);
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				point = new Point();
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("native point creation", castTime);
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				rec = new Rectangle();
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("native rect creation", castTime);
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				vect3 = new Vector3D();
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("Vect3D creation", castTime);
			
		}
	}
}
